import Vue from 'vue'
import App from './App'
import ElementUI from 'element-ui'
import '../common/drag'
import 'font-awesome/css/font-awesome.min.css'
import 'leaflet/dist/leaflet.css'
import 'element-ui/lib/theme-chalk/index.css'
import '../asset/css/base.css'
import '../asset/css/ct2dmap.css'
import VueRouter from 'vue-router'
import routes from './routes'
import Model from '../models'
import moment from 'moment'
import shortcuts from "./charts/shortcut.vue"
Vue.prototype.shortcuts = shortcuts.shortcuts
    // The following dependencies can be selectively loaded on demand
import 'echarts/lib/component/markLine';
import 'echarts/lib/component/markPoint';
import 'echarts/lib/component/markArea';
import 'echarts/lib/component/visualMap';
import 'echarts/lib/component/dataZoom';
import 'echarts/lib/component/toolbox';
import 'echarts/lib/component/title';
import 'zrender/lib/svg/svg';
import preview from 'vue-photo-preview'
import 'vue-photo-preview/dist/skin.css'
// import 'vue-orgchart/dist/style.min.css'
import '../asset/css/style.min.css'
// import orgChart from 'vue-orgchart'
Vue.use(preview)
Vue.use(ElementUI)
Vue.use(VueRouter)
    // Vue.use(orgChart)
Model(Vue)
Vue.filter('dateformat', function(dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
    return moment(dataStr).format(pattern)

})
var options = {
    fullscreenEl: false //关闭全屏按钮
}

Vue.use(vuePhotoPreview, options)
const router = new VueRouter({
    routes
})
router.beforeEach((to, from, next) => {
        try {
            if (to.path == '/login') {
                sessionStorage.removeItem('token');
            }
            let token = sessionStorage.getItem('token');
            if (!token && to.path != '/login') {
                next({ path: '/login' })
            } else {
                next()
            }



        } catch (err) {
            console.log(err);
        }
    })
    //router.afterEach(transition => {
    //NProgress.done();
    //});

new Vue({
    router,
    render: h => h(App)
}).$mount('#app')